package dao;

import java.util.List;

import org.hibernate.Query;

import bean.WechatCache;

public class WechatCacheDAOImpl extends WechatCacheDAO {

    /**
     * Get last cache from database
     * @return
     */
    public List<WechatCache> findLast() {
        log.debug("finding last WechatCache instance with property");
        try {
            String queryString = "from WechatCache as model order by model.id desc";
            Query queryObject = getCurrentSession().createQuery(queryString).setFirstResult(0).setMaxResults(1);
            return queryObject.list();
        } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
        }
    }

}
